#include <ctime>
#include <iostream>
#include <fstream>

using namespace std;

void S1(int ABC[], int AF) {
	while(AF--) 	{
		bool gf = false;
		
		for(int i = 0; i < AF; i++) {
			if(ABC[i] > ABC[i + 1]){
				swap(ABC[i], ABC[i + 1]);
				gf = true;
			}
		}	
	
		if(gf == false) break;
	}
}

void read_from_file(const char *filename, int a[], int length) {
    ifstream file(filename);

    for(int i=0; i < length; i++)
        file >> a[i];
}

int main()
{
    #define LEN 5000
    int a[LEN];

    read_from_file("m1_sorted.txt",a,LEN);
    unsigned int t1 =  clock(); 
    S1(a,LEN);
    unsigned int t2 = clock(); 
    unsigned int t3 = t2 - t1; 
    cout<<"m1_sorted " << t3 << " milliseconds \n";
    
    read_from_file("m2_reverse.txt",a,LEN);
    t1 =  clock(); 
    S1(a,LEN);
    t2 = clock(); 
    t3 = t2 - t1; 
    cout<<"m2_reverse " << t3 << " milliseconds \n";
    
    read_from_file("m3_shuffle.txt",a,LEN);
    t1 =  clock();
    S1(a,LEN);
    t2 = clock();
    t3 = t2 - t1;
    cout<<"m3_shuffle " << t3 << " milliseconds \n";
    
    return 0;
}